﻿using Abp.Localization;
using Pub.Class;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using LeiliTech.@(Model.ConfigInfo.ModelFolderName).Dto;
using LeiliTech.@(Model.ConfigInfo.ModelFolderName);
using LeiliTech.MES.Web.Controllers;

namespace LeiliTech.MES.Web.Areas.@(Model.ConfigInfo.ModelFolderName)Manage.Controllers
{
    public class @(Model.ConfigInfo.EntityName)Controller : BaseController
    {
        I@(Model.ConfigInfo.EntityName)AppService _BaseAppService = null;
        public @(Model.ConfigInfo.EntityName)Controller(I@(Model.ConfigInfo.EntityName)AppService baseappservice)
        {
            _BaseAppService = baseappservice;
        }
        /// <summary>
        /// 列表 页面
        ///</summary>
        /// <returns></returns>
        public ActionResult Index()
        {
            return View();
        }

        public ActionResult Add()
        {
		    ViewBag.oper = "Add";
            return View("Edit");
        }

        public ActionResult Edit(string id)
        {
            ViewBag.id = id;
			ViewBag.oper = "Edit";
            return View();
        }
        
        #region 获取数据
        /// <summary>
        /// 分页获取信息
        /// </summary>
        /// <returns></returns>
        public JsonResult QueryPage(@(Model.ConfigInfo.EntityName)Input input)
        {
            var result = _BaseAppService.QueryPage(input);
            return Json(result, JsonRequestBehavior.AllowGet);
        }

        /// <summary>
        /// 获得实体对象json
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult GetEntity(string id)
        {
            var result = _BaseAppService.GetEntity(id);
            return Json(result, JsonRequestBehavior.AllowGet);
        }
        /// <summary>
        /// 保存
        /// </summary>
        /// <param name="inputEntity"></param>
        /// <returns></returns>
        public string SaveEntity(@(Model.ConfigInfo.EntityName)Dto inputEntity)
        {
            var result = _BaseAppService.SaveEntity(inputEntity);
            return result;
        }

        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public int DeleteEntity(List<string> ids)
        {
            return _BaseAppService.DeleteEntity(ids);
        }

        #endregion
        }
    }